package com.hollis公众号.防止序列化破坏单例模式;

import java.io.Serializable;

public class Singleton2 implements Serializable {

	private volatile static Singleton2 singleton;

	private Singleton2(){}

	public static Singleton2 getSingleton(){
		if(singleton == null){
			synchronized (Singleton2.class) {
				if(singleton == null){
					singleton = new Singleton2();
				}
			}
		}
		return singleton;
	}

	private Object readResolve(){
		return singleton;
	}

}
